/*
 * Shooter.cpp
 *
 *  Created on: Sep 30, 2012
 *      Author: Administrator
 */

#include "Shooter.h"

using namespace Osp::Media;
using namespace Osp::Io;
using namespace Osp::Base;

Shooter::Shooter() {
	camera = new Camera();
	AppLog("Camera created");
	camera -> Construct(*this, CAMERA_PRIMARY);
	AppLog("Camera constructed");
	camera -> PowerOn();
	AppLog("Camera turned on");
	camera -> StartPreview(null, false);
	AppLog("Camera started preview");
	camera -> Capture();
	AppLog("Camera captures photo");
}

Shooter::~Shooter() {
	// TODO Auto-generated destructor stub
}

void
Shooter::OnCameraAutoFocused (bool completeCondition) {
	AppLog("Camera autofocused");
}

void
Shooter::OnCameraCaptured (Osp::Base::ByteBuffer &capturedData, result r) {

	AppLog("Camera captured");

	File file;
	String fileName(L"/Home/bada.jpg");
	result r1 = E_SUCCESS;
	r1 = file.Construct(fileName, L"w");
	file.Write(capturedData);
	file.Flush();

}

void
Shooter::OnCameraErrorOccurred (Osp::Media::CameraErrorReason r) {
	AppLog("Camera error");
}

void
Shooter::OnCameraPreviewed (Osp::Base::ByteBuffer &previewedData, result r) {
	AppLog("Camera previewed");
}
